﻿@{
    ViewBag.Title = "ProjectSchedules";
    Layout = "~/Views/Shared/_Base.cshtml";
}
<div class="row-fluid">
    <div class="span12">
        <table border="0" width="100%">
            <tr>
                <td width="10%" align="center">
                    项目编号:
                </td>
                <td>
                    <input id="txtProjectCode" type="text" class="input-medium search-query" placeholder="请使用项目编码进行查询"
                        style="width: 300px; background-color: #fff;" />
                    <button class="btn btn-primary btn-small" id="btnSearch">
                        查询
                    </button>
                </td>
            </tr>
        </table>
    </div>
</div>
<hr />

<table id="grid" class="mmg">
</table>
<div id="pg" style="text-align: right;">
</div>
@section tail{
    <script src="/content/plugins/mmgrid/mmGrid.js" type="text/javascript"></script>
    <script src="/content/plugins/mmgrid/mmPaginator.js" type="text/javascript"></script>
    <script type="text/javascript">
        var cols = [
            { title: '项目编码', name: 'ProjectCode', width: 20, align: 'center' },
            { title: '项目名称', name: 'ProjectName', width: 65, align: 'center', renderer: function (val, item, index) {
                return item['ProductName'] + ' ' + item['ProjectTitle'];
            } 
            },
            { title: '借款企业', name: 'EnterpriseName', width: 65, align: 'center' },
            { title: '借款金额', name: 'Financing', width: 15, align: 'center', renderer: function (val, item, index) {
                return "￥" + Number(item["Financing"] / 10000).toFixed(2) + "万元";
            }
            },
            { title: '融资进度', name: 'Schedule', width: 15, align: 'center', renderer: function (val, item, index) {
                var percent = parseFloat(item["Invested"]) / parseFloat(item["Financing"]);
                var style = percent <= 0.5 ? "progress-info" : percent < 1 ? "progress-warning" : "progress-success";

                return '<div class="progress ' + style + ' progress-striped" style="margin: 10px 0;">' +
                                '<div class="bar" style="width:' + parseInt((percent * 100).toString(), 10) + '%"></div>' +
                                '</div>';
            }
            },
            { title: '操作', name: '', width: 220, align: 'center', lockWidth: true, lockDisplay: true, renderer: function (val, item, index) {
                var html = '<button  class="btn btn-info btn-mini" onclick="projectShow(\'' + item["ID"] + '\', 2)">详情</button>';
                if (item["CreateUser"] == '@(HttpContext.Current.User.Identity.Name)') {
                    if (item["Status"] == 0) {
                        html += ' <button  class="btn btn-info btn-mini" onclick="projectShow(\'' + item["ID"] + '\', 1)">修改</button>';
                        html += ' <button  class="btn btn-info btn-mini" onclick="changeProjectStatus(\'' + item["ID"] + '\', 1)">审核</button>';
                        html += ' <button  class="btn btn-danger btn-mini" onclick="changeProjectStatus(\'' + item["ID"] + '\', 99)">删除</button>';
                    }
                }
                return html;
            }
            }
        ];

        var mmg;
        $(function () {

            mmg = $('#grid').mmGrid({
                indexCol: true,
                indexColWidth: 25,
                height: $("body", parent.document).height() - 220,
                cols: cols,
                url: '/Project/LoadProjectSchedules',
                params: { },
                method: 'get',
                remoteSort: true,
                //items: items
                //sortName: 'SECUCODE',
                //sortStatus: 'asc',
                multiSelect: false,
                checkCol: false,
                fullWidthRows: true,
                autoLoad: false,
                plugins: [
                        $('#pg').mmPaginator()
                    ]
            });
            mmg.load();
        });


    </script>
}
